class AddDeterminism < Formula
  desc "Build postprocessor to reset metadata fields for build reproducibility"
  homepage "https://github.com/keszybz/add-determinism"
  url "https://github.com/keszybz/add-determinism/archive/refs/tags/v0.7.0.tar.gz"
  sha256 "ff23770171a16e8e9df97bfeacaccd9545e5a55157cada5f76ecc9aa5762698c"
  license "GPL-3.0-or-later"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_linux:  "5a1f38d1d36f4c56ee8a025f92c03984e4d38fccc6f01791c6aed66876bab144"
    sha256 cellar: :any_skip_relocation, x86_64_linux: "831ddbdb5f413ad31507abe11a6ad88e3f591439600a32c3bda7e27eee969c4e"
  end

  depends_on "rust" => :build
  depends_on :linux
  depends_on "zlib"

  def install
    system "cargo", "install", *std_cargo_args
  end

  test do
    (testpath/"test.html").write <<~EOS
      <!-- Generated by javadoc (1.2.3) on 2025-01-01 -->
      <meta name="dc.created" content="2025-01-01">
    EOS

    ENV["SOURCE_DATE_EPOCH"] = "0"
    system bin/"add-det", testpath/"test.html"

    assert_match "<!-- Generated by javadoc -->", (testpath/"test.html").read
    assert_match "content=\"1970-01-01\"", (testpath/"test.html").read
  end
end
